<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择人员信息</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>


<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <select name="sex" lay-filter="sex" >
                                <option value="">请选择</option>
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="tel" id="tel" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">人员性质</label>
                        <div class="layui-input-block">
                            <div id="nature" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">签约/入职日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="intodt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">社保状态</label>
                        <div class="layui-input-block">
                            <div id="social" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">参保地</label>
                        <div class="layui-input-block">
                            <input type="text" name="socialareas" id="socialareas" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">参保开始月份</label>
                        <div class="layui-input-block">
                            <input type="text" name="socstartdt" readonly placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ym">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_domkey = getQueryVariable('domkey');
    var parent_page = getQueryVariable('page');

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_opt_get_cert_person),where: {parentpage:parent_page}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: ['', '', ''],filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function(res){

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                xmselect_dan('nature', res.data.nature, res.data.is_nature, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                xmselect_dan('social', res.data.social, res.data.is_social, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            ,cols: [[
                {type:choose_type,fixed:'left'}
                ,{type: 'numbers',title:'序号',fixed:'left'}
                ,{field: 'name', title: '姓名',fixed:'left'}
                ,{field: 'sex', title: '性别'}
                ,{field: 'age', title: '年龄'}
                ,{field: 'nature_name', title: '人员性质'}
                ,{field: 'chanid_name', title: '所属单位'}
                ,{field: 'idcarddt', title: '身份证有效期'}
                ,{field: 'social_name', title: '社保状态'}
                ,{field: 'socialareas', title: '参保地'}
                ,{field: 'socstartdt', title: '参保开始月份'}
                ,{field: 'socnum', title: '连续参保月份数'}
                ,{field: 'cert_num', title: '证书数量',event:'cert_num'}
                ,{field: 'statueuse_name', title: '人员使用情况'}
            ]]
            ,done : function(res, curr, count){
                soulTable.render(this);
            }
        });
        listTableSearch(form, table);

        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length === 0){
                facade.error('请选择数据'); return false;
            }

            if(parent_page === 'wage'){
                var str = '';
                var nums = $("#list_list tr", parent.document).length;
                for (var key in data){
                    nums++;
                    str += '<tr>';
                    str += '<td style="width: 45px">'+nums+'</td>';
                    str += '<td><input type="text" class="layui-input name" value="'+data[key].name+'"></td>';
                    str += '<td><input type="text" class="layui-input deptname" value="'+data[key].deptid_name+'"></td>';
                    str += '<td><input type="text" class="layui-input gangname" value="'+data[key].gangid_name+'"></td>';
                    str += '<td><input type="number" class="layui-input jiben"></td>';
                    str += '<td><input type="number" class="layui-input gangbu"></td>';
                    str += '<td><input type="number" class="layui-input quanqin"></td>';
                    str += '<td><input type="number" class="layui-input kaohe"></td>';
                    str += '<td><input type="number" class="layui-input jiaban"></td>';
                    str += '<td><input type="number" class="layui-input jiang"></td>';
                    str += '<td><input type="number" class="layui-input yewu"></td>';
                    str += '<td><input type="number" class="layui-input qiying"></td>';
                    str += '<td><input type="number" class="layui-input yingfee"></td>';
                    str += '<td><input type="number" class="layui-input chidao"></td>';
                    str += '<td><input type="number" class="layui-input bing"></td>';
                    str += '<td><input type="number" class="layui-input kuang"></td>';
                    str += '<td><input type="number" class="layui-input shebao"></td>';
                    str += '<td><input type="number" class="layui-input gongjin"></td>';
                    str += '<td><input type="number" class="layui-input geshui"></td>';
                    str += '<td><input type="number" class="layui-input qikou"></td>';
                    str += '<td><input type="number" class="layui-input koufee"></td>';
                    str += '<td><input type="number" class="layui-input money"></td>';
                    str += '<td><input type="text" class="layui-input explain"></td>';
                    str += '</tr>';
                }
                $("#list_list", parent.document).append(str);
                if (typeof(window.parent.update_refresh_row_func)!="undefined"){
                    window.parent.update_refresh_row_func();
                }
            }else if(parent_page === 'archive_diao'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);

                $("#deptname" , parent.document).val(data[0].deptid_name);
                $("#gangname" , parent.document).val(data[0].gangid_name);

            }else if(parent_page === 'archive_zhuan'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);

                $("#intodt" , parent.document).val(data[0].intodt);
                $("#deptname" , parent.document).val(data[0].deptid_name);
                $("#gangname" , parent.document).val(data[0].gangid_name);

            }else if(parent_page === 'archive_out'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);

                $("#intodt" , parent.document).val(data[0].intodt);
                $("#deptname" , parent.document).val(data[0].deptid_name);
                $("#gangname" , parent.document).val(data[0].gangid_name);
                $("#outdt" , parent.document).val(data[0].outdt);
                parent.xmselect_dan('outtype', parent.outtype, data[0].outtype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#outtype").find('xm-select').removeClass('error');
                    }else{
                        $("#outtype").find('xm-select').addClass('error');
                    }
                });

            }else if(parent_page === 'cert_employ'){
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+'' +
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);

                parent.xmselect_dan('person_nature', parent.person_nature, data[0].nature, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#person_nature").find('xm-select').removeClass('error');
                    }else{
                        $("#person_nature").find('xm-select').addClass('error');
                    }
                });

            }else{
                var str = '<button type="button" class="layui-btn layui-btn-sm btn-dark" key="'+data[0].id+'"><span class="choose_content">'+data[0].name+
                    '</span><span class="choose_close" onclick="choose_close(this, \''+parent_dom+'\')">×</span></button>';
                $("#"+parent_dom , parent.document).html(str);
                parent.formValid(parent_dom);
            }

            layer_close();
        });

        // 清空
        $('#empty').on('click', function () {
            $("#"+parent_dom+'_name' , parent.document).val('');
            $("#"+parent_dom , parent.document).val('');
            layer_close();
        });



    });



    function auth_but_func_add_flow(){
        openPageEdit('../dealcom/flow_add.php?close=1');
    }
</script>
</body>
</html>
